home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / X11 / xpm.h.z / xpm.h
C/C++ Source or Header  |  1996-09-20  |  15KB  |  440 lines

  1. /*
  2.  * Copyright (C) 1989-95 GROUPE BULL
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a copy
  5.  * of this software and associated documentation files (the "Software"), to
  6.  * deal in the Software without restriction, including without limitation the
  7.  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8.  * sell copies of the Software, and to permit persons to whom the Software is
  9.  * furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice shall be included in
  12.  * all copies or substantial portions of the Software.
  13.  *
  14.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17.  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18.  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19.  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  *
  21.  * Except as contained in this notice, the name of GROUPE BULL shall not be
  22.  * used in advertising or otherwise to promote the sale, use or other dealings
  23.  * in this Software without prior written authorization from GROUPE BULL.
  24.  */
  25.  
  26. /*****************************************************************************\
  27. * xpm.h:                                                                      *
  28. *                                                                             *
  29. *  XPM library                                                                *
  30. *  Include file                                                               *
  31. *                                                                             *
  32. *  Developed by Arnaud Le Hors                                                *
  33. \*****************************************************************************/
  34.  
  35. /*
  36.  * The code related to FOR_MSW has been added by
  37.  * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
  38.  */
  39.  
  40. #ifndef XPM_h
  41. #define XPM_h
  42.  
  43. /*
  44.  * first some identification numbers:
  45.  * the version and revision numbers are determined with the following rule:
  46.  * SO Major number = LIB minor version number.
  47.  * SO Minor number = LIB sub-minor version number.
  48.  * e.g: Xpm version 3.2f
  49.  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
  50.  *      thus we have XpmVersion = 2 and XpmRevision = 6
  51.  *      which gives  SOXPMLIBREV = 2.6
  52.  *
  53.  * Then the XpmIncludeVersion number is built from these numbers.
  54.  */
  55. #define XpmFormat 3
  56. #define XpmVersion 4
  57. #define XpmRevision 6
  58. #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
  59.  
  60. #ifndef XPM_NUMBERS
  61.  
  62. #ifdef FOR_MSW
  63. #define SYSV            /* uses memcpy string.h etc. */
  64. #include <malloc.h>
  65. #include "simx.h"        /* defines some X stuff using MSW types */
  66. #define NEED_STRCASECMP        /* at least for MSVC++ */
  67. #else /* FOR_MSW */
  68. #include <X11/Xlib.h>
  69. #include <X11/Xutil.h>
  70. #endif /* FOR_MSW */
  71.  
  72. /* let's define Pixel if it is not done yet */
  73. #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
  74. typedef unsigned long Pixel;    /* Index into colormap */
  75. #define PIXEL_ALREADY_TYPEDEFED
  76. #endif
  77.  
  78. /* Return ErrorStatus codes:
  79.  * null     if full success
  80.  * positive if partial success
  81.  * negative if failure
  82.  */
  83.  
  84. #define XpmColorError    1
  85. #define XpmSuccess       0
  86. #define XpmOpenFailed   -1
  87. #define XpmFileInvalid  -2
  88. #define XpmNoMemory     -3
  89. #define XpmColorFailed  -4
  90.  
  91. /* the following should help people wanting to use their own functions */
  92. #define XpmFree(ptr) free(ptr)
  93.  
  94. typedef struct {
  95.     char *name;            /* Symbolic color name */
  96.     char *value;        /* Color value */
  97.     Pixel pixel;        /* Color pixel */
  98. }      XpmColorSymbol;
  99.  
  100. typedef struct {
  101.     char *name;            /* name of the extension */
  102.     unsigned int nlines;    /* number of lines in this extension */
  103.     char **lines;        /* pointer to the extension array of strings */
  104. }      XpmExtension;
  105.  
  106. typedef struct {
  107.     char *string;        /* characters string */
  108.     char *symbolic;        /* symbolic name */
  109.     char *m_color;        /* monochrom default */
  110.     char *g4_color;        /* 4 level grayscale default */
  111.     char *g_color;        /* other level grayscale default */
  112.     char *c_color;        /* color default */
  113. }      XpmColor;
  114.  
  115. typedef struct {
  116.     unsigned int width;        /* image width */
  117.     unsigned int height;    /* image height */
  118.     unsigned int cpp;        /* number of characters per pixel */
  119.     unsigned int ncolors;    /* number of colors */
  120.     XpmColor *colorTable;    /* list of related colors */
  121.     unsigned int *data;        /* image data */
  122. }      XpmImage;
  123.  
  124. typedef struct {
  125.     unsigned long valuemask;    /* Specifies which attributes are defined */
  126.     char *hints_cmt;        /* Comment of the hints section */
  127.     char *colors_cmt;        /* Comment of the colors section */
  128.     char *pixels_cmt;        /* Comment of the pixels section */
  129.     unsigned int x_hotspot;    /* Returns the x hotspot's coordinate */
  130.     unsigned int y_hotspot;    /* Returns the y hotspot's coordinate */
  131.     unsigned int nextensions;    /* number of extensions */
  132.     XpmExtension *extensions;    /* pointer to array of extensions */
  133. }      XpmInfo;
  134.  
  135. typedef struct {
  136.     unsigned long valuemask;        /* Specifies which attributes are
  137.                      * defined */
  138.  
  139.     Visual *visual;            /* Specifies the visual to use */
  140.     Colormap colormap;            /* Specifies the colormap to use */
  141.     unsigned int depth;            /* Specifies the depth */
  142.     unsigned int width;            /* Returns the width of the created
  143.                      * pixmap */
  144.     unsigned int height;        /* Returns the height of the created
  145.                      * pixmap */
  146.     unsigned int x_hotspot;        /* Returns the x hotspot's
  147.                      * coordinate */
  148.     unsigned int y_hotspot;        /* Returns the y hotspot's
  149.                      * coordinate */
  150.     unsigned int cpp;            /* Specifies the number of char per
  151.                      * pixel */
  152.     Pixel *pixels;            /* List of used color pixels */
  153.     unsigned int npixels;        /* Number of pixels */
  154.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  155.                      * override */
  156.     unsigned int numsymbols;        /* Number of symbols */
  157.     char *rgb_fname;            /* RGB text file name */
  158.     unsigned int nextensions;        /* number of extensions */
  159.     XpmExtension *extensions;        /* pointer to array of extensions */
  160.  
  161.     unsigned int ncolors;               /* Number of colors */
  162.     XpmColor *colorTable;               /* Color table pointer */
  163. /* 3.2 backward compatibility code */
  164.     char *hints_cmt;                    /* Comment of the hints section */
  165.     char *colors_cmt;                   /* Comment of the colors section */
  166.     char *pixels_cmt;                   /* Comment of the pixels section */
  167. /* end 3.2 bc */
  168.     unsigned int mask_pixel;            /* Transparent pixel's color table
  169.                                          * index */
  170.  
  171.     /* Color Allocation Directives */
  172.     unsigned int exactColors;        /* Only use exact colors for visual */
  173.     unsigned int closeness;        /* Allowable RGB deviation */
  174.     unsigned int red_closeness;        /* Allowable red deviation */
  175.     unsigned int green_closeness;    /* Allowable green deviation */
  176.     unsigned int blue_closeness;    /* Allowable blue deviation */
  177.     int color_key;            /* Use colors from this color set */
  178.  
  179. }      XpmAttributes;
  180.  
  181. /* XpmAttributes value masks bits */
  182. #define XpmVisual       (1L<<0)
  183. #define XpmColormap       (1L<<1)
  184. #define XpmDepth       (1L<<2)
  185. #define XpmSize           (1L<<3)    /* width & height */
  186. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  187. #define XpmCharsPerPixel   (1L<<5)
  188. #define XpmColorSymbols       (1L<<6)
  189. #define XpmRgbFilename       (1L<<7)
  190. /* 3.2 backward compatibility code */
  191. #define XpmInfos       (1L<<8)
  192. #define XpmReturnInfos       XpmInfos
  193. /* end 3.2 bc */
  194. #define XpmReturnPixels       (1L<<9)
  195. #define XpmExtensions      (1L<<10)
  196. #define XpmReturnExtensions XpmExtensions
  197.  
  198. #define XpmExactColors     (1L<<11)
  199. #define XpmCloseness       (1L<<12)
  200. #define XpmRGBCloseness       (1L<<13)
  201. #define XpmColorKey       (1L<<14)
  202.  
  203. #define XpmColorTable      (1L<<15)
  204. #define XpmReturnColorTable XpmColorTable
  205.  
  206. /* XpmInfo value masks bits */
  207. #define XpmComments        XpmInfos
  208. #define XpmReturnComments  XpmComments
  209.  
  210. /* XpmAttributes mask_pixel value when there is no mask */
  211. #ifndef FOR_MSW
  212. #define XpmUndefPixel 0x80000000
  213. #else
  214. /* int is only 16 bit for MSW */
  215. #define XpmUndefPixel 0x8000
  216. #endif
  217.  
  218. /*
  219.  * color keys for visual type, they must fit along with the number key of
  220.  * each related element in xpmColorKeys[] defined in xpmP.h
  221.  */
  222. #define XPM_MONO    2
  223. #define XPM_GREY4    3
  224. #define XPM_GRAY4    3
  225. #define XPM_GREY     4
  226. #define XPM_GRAY     4
  227. #define XPM_COLOR    5
  228.  
  229.  
  230. /*
  231.  * minimal portability layer between ansi and KR C
  232.  */
  233.  
  234. /* forward declaration of functions with prototypes */
  235.  
  236. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  237.  /* ANSI || C++ */
  238. #define FUNC(f, t, p) extern t f p
  239. #define LFUNC(f, t, p) static t f p
  240. #else  /* K&R */
  241. #define FUNC(f, t, p) extern t f()
  242. #define LFUNC(f, t, p) static t f()
  243. #endif /* end of K&R */
  244.  
  245.  
  246. /*
  247.  * functions declarations
  248.  */
  249.  
  250. #ifdef __cplusplus
  251. extern "C" {
  252. #endif
  253.  
  254. /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
  255.  
  256. #ifndef FOR_MSW
  257.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  258.                     Drawable d,
  259.                     char **data,
  260.                     Pixmap *pixmap_return,
  261.                     Pixmap *shapemask_return,
  262.                     XpmAttributes *attributes));
  263.  
  264.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  265.                     char ***data_return,
  266.                     Pixmap pixmap,
  267.                     Pixmap shapemask,
  268.                     XpmAttributes *attributes));
  269.  
  270.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  271.                     Drawable d,
  272.                     char *filename,
  273.                     Pixmap *pixmap_return,
  274.                     Pixmap *shapemask_return,
  275.                     XpmAttributes *attributes));
  276.  
  277.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  278.                        char *filename,
  279.                        Pixmap pixmap,
  280.                        Pixmap shapemask,
  281.                        XpmAttributes *attributes));
  282. #endif  /* ndef FOR_MSW */
  283.  
  284.     FUNC(XpmCreateImageFromData, int, (Display *display,
  285.                        char **data,
  286.                        XImage **image_return,
  287.                        XImage **shapemask_return,
  288.                        XpmAttributes *attributes));
  289.  
  290.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  291.                        char ***data_return,
  292.                        XImage *image,
  293.                        XImage *shapeimage,
  294.                        XpmAttributes *attributes));
  295.  
  296.     FUNC(XpmReadFileToImage, int, (Display *display,
  297.                    char *filename,
  298.                    XImage **image_return,
  299.                    XImage **shapeimage_return,
  300.                    XpmAttributes *attributes));
  301.  
  302.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  303.                       char *filename,
  304.                       XImage *image,
  305.                       XImage *shapeimage,
  306.                       XpmAttributes *attributes));
  307.  
  308.     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
  309.                      char *buffer,
  310.                      XImage **image_return,
  311.                      XImage **shapemask_return,
  312.                      XpmAttributes *attributes));
  313. #ifndef FOR_MSW
  314.     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
  315.                       Drawable d,
  316.                       char *buffer,
  317.                       Pixmap *pixmap_return,
  318.                       Pixmap *shapemask_return,
  319.                       XpmAttributes *attributes));
  320.  
  321.     FUNC(XpmCreateBufferFromImage, int, (Display *display,
  322.                      char **buffer_return,
  323.                      XImage *image,
  324.                      XImage *shapeimage,
  325.                      XpmAttributes *attributes));
  326.  
  327.     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
  328.                       char **buffer_return,
  329.                       Pixmap pixmap,
  330.                       Pixmap shapemask,
  331.                       XpmAttributes *attributes));
  332. #endif  /* ndef FOR_MSW */
  333.     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
  334.     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
  335.  
  336.     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
  337.     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
  338.  
  339.     FUNC(XpmAttributesSize, int, ());
  340.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  341.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
  342.                    int nextensions));
  343.  
  344.     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
  345.     FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
  346.     FUNC(XpmGetErrorString, char *, (int errcode));
  347.     FUNC(XpmLibraryVersion, int, ());
  348.  
  349.     /* XpmImage functions */
  350.     FUNC(XpmReadFileToXpmImage, int, (char *filename,
  351.                       XpmImage *image,
  352.                       XpmInfo *info));
  353.  
  354.     FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
  355.                      XpmImage *image,
  356.                      XpmInfo *info));
  357. #ifndef FOR_MSW
  358.     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
  359.                         Drawable d,
  360.                         XpmImage *image,
  361.                         Pixmap *pixmap_return,
  362.                         Pixmap *shapemask_return,
  363.                         XpmAttributes *attributes));
  364. #endif
  365.     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
  366.                        XpmImage *image,
  367.                        XImage **image_return,
  368.                        XImage **shapeimage_return,
  369.                        XpmAttributes *attributes));
  370.  
  371.     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
  372.                        XImage *image,
  373.                        XImage *shapeimage,
  374.                        XpmImage *xpmimage,
  375.                        XpmAttributes *attributes));
  376. #ifndef FOR_MSW
  377.     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
  378.                         Pixmap pixmap,
  379.                         Pixmap shapemask,
  380.                         XpmImage *xpmimage,
  381.                         XpmAttributes *attributes));
  382. #endif
  383.     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
  384.                       XpmImage *image,
  385.                       XpmInfo *info));
  386.  
  387.     FUNC(XpmCreateXpmImageFromData, int, (char **data,
  388.                       XpmImage *image,
  389.                       XpmInfo *info));
  390.  
  391.     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
  392.                         XpmImage *image,
  393.                         XpmInfo *info));
  394.  
  395.     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
  396.                         XpmImage *image,
  397.                         XpmInfo *info));
  398.  
  399. #ifdef __cplusplus
  400. } /* for C++ V2.0 */
  401. #endif
  402.  
  403.  
  404. /* backward compatibility */
  405.  
  406. /* for version 3.0c */
  407. #define XpmPixmapColorError  XpmColorError
  408. #define XpmPixmapSuccess     XpmSuccess
  409. #define XpmPixmapOpenFailed  XpmOpenFailed
  410. #define XpmPixmapFileInvalid XpmFileInvalid
  411. #define XpmPixmapNoMemory    XpmNoMemory
  412. #define XpmPixmapColorFailed XpmColorFailed
  413.  
  414. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  415.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  416. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  417.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  418.  
  419. /* for version 3.0b */
  420. #define PixmapColorError  XpmColorError
  421. #define PixmapSuccess     XpmSuccess
  422. #define PixmapOpenFailed  XpmOpenFailed
  423. #define PixmapFileInvalid XpmFileInvalid
  424. #define PixmapNoMemory    XpmNoMemory
  425. #define PixmapColorFailed XpmColorFailed
  426.  
  427. #define ColorSymbol XpmColorSymbol
  428.  
  429. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  430.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  431. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  432.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  433. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  434.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  435. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  436.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  437.  
  438. #endif /* XPM_NUMBERS */
  439. #endif
  440.